package com.tsystems.tuni.sportplanet.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlTransient;

/**
 * Company Entity.
 * 
 * @author Yuriy Eremin
 * 
 */
@Entity
@Table(name = "company", catalog = "sportsplanet")
public class Company implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Integer companyId;
	private String companyName;
	private String email;
	private Set<Department> departments = new HashSet<Department>(0);
	private Set<Team> teams = new HashSet<Team>(0);

	public Company() {
	}

	public Company(Integer id, String companyName, String email) {
		this.companyId = id;
		this.companyName = companyName;
	}

	public Company(String companyName, String email) {
		this.companyName = companyName;
	}

	public Company(String companyName, String email,
			Set<Department> departments, Set<Team> teams) {
		this.companyName = companyName;
		this.departments = departments;
		this.teams = teams;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "company_id", unique = true, nullable = false)
	public Integer getCompanyId() {
		return this.companyId;
	}

	public void setCompanyId(Integer companyId) {
		this.companyId = companyId;
	}

	@Column(name = "company_name", length = 45, nullable = false)
	public String getCompanyName() {
		return this.companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	@Column(name = "email", length = 90, nullable = false)
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "company")
	@XmlTransient
	public Set<Department> getDepartments() {
		return this.departments;
	}

	public void setDepartments(Set<Department> departments) {
		this.departments = departments;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "company")
	@XmlTransient
	public Set<Team> getTeams() {
		return this.teams;
	}

	public void setTeams(Set<Team> teams) {
		this.teams = teams;
	}

	@Override
	public String toString() {
		return companyName;
	}

}
